
//
//  cinemaViewController.m
//  ui豆瓣
//
//  Created by lirui on 15/12/23.
//  Copyright © 2015年 www.lanou3g.com蓝鸥科技. All rights reserved.
//

#import "cinemaViewController.h"
#import "cinemamodel.h"
#import "cinemaTableViewCell.h"
@interface cinemaViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic ,retain)UITableView *tableview;
@property(nonatomic, retain)NSMutableArray *cArr;
@end

@implementation cinemaViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [ UIColor whiteColor];
    self.navigationItem.title = @"影院";
    self.tableview = [[ UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableview.backgroundColor = [ UIColor whiteColor];
    [self.view addSubview:self.tableview];
    self.tableview.dataSource =self;
    _tableview.delegate = self;
    //导航栏适应边界适应屏幕
    self.tableview.contentInset = UIEdgeInsetsMake(0, 0,64, 0);
    NSString *path = [[ NSBundle mainBundle] pathForResource:@"cinema" ofType:@"plist"];
     NSArray *tempArr = [ NSArray arrayWithContentsOfFile:path];
//    _cArr = [NSMutableArray array ];
//    for (NSDictionary *dic in tempArr) {
//           cinemamodel *mov = [[cinemamodel alloc] init];
//            [mov setValuesForKeysWithDictionary:dic];
//            [_cArr addObject:mov];
    _cArr = [ cinemamodel modelHanderWithArray:tempArr];
//    }
     [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg.png"]forBarMetrics:UIBarMetricsDefault];
    [self.tableview registerClass:[cinemaTableViewCell class] forCellReuseIdentifier:@"cell"];
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _cArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    cinemaTableViewCell *cell = [ tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cinemamodel *m = _cArr[ indexPath.row];
    cell.namelabel.text = m.cinemaName;
    cell.adresslabel.text = m .address;
    cell.phonelabel.text = m.telephone;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ //得到label高度
    CGFloat h = [ cinemaTableViewCell heightWithText:[_cArr[ indexPath.row] address ]];
 
    return h+ 60 +20 ;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
